package com.compress4j.arithmetic;

import java.io.IOException;
/**
 * 
 * @author brunopierre4@yahoo.fr
 * Interface of an arithmetic decoder
 */
public interface ArithmeticDecoder {

	/** Read the position for the given max<br>
	 * Caller <b>MUST</b> detect in which range this value is and then call hasDecoded method with this range
     * @throws IOException exception from the encapsultated inputstream.
     * @return the value readed which must verify 0<=value<max
     */
	int read(int max) throws IOException;
	
	/** Tell to the decoder which range has been used<br>
	 * It <b>MUST</b> be the same that was used for encoding, it <b>MUST</b> be call after each read<br>
	 * And of course if readed is the result of .read(total) we <b>MUST</b> verify:<br> 0 <= start <= readed < end <= max
	 * @param start
	 * @param end
	 * @param max
     * @throws IOException exception from the encapsultated inputstream.
     */
	void hasDecoded(int start, int end, int max) throws IOException;

	/** Close the underlying inputstream
     * @throws IOException exception from the encapsultated inputstream.
     */
	void close() throws IOException;

}